//-----------------------------------------
//	DepthMap
//-----------------------------------------

//------------------
//--- Parameters ---
float4x4 World;
float4x4 View;
float4x4 Projection;
float MaxDepth;

//------------------
//--- Structures ---
struct VertexShaderInput
{
	float4 Position : POSITION;
};

struct VertexShaderOutput
{
	float4 Position : POSITION;
	float4 Color : COLOR0;
};

struct PixelShaderInput
{
	float4 Color : COLOR0;
};

//--------------------
//--- VertexShader ---
VertexShaderOutput SimpleVertexShader(VertexShaderInput input)
{
	VertexShaderOutput output;
	output.Position = mul(mul(mul(input.Position, World), View), Projection);
	output.Color = output.Position.z / MaxDepth;
	
	return  output;
}

//-------------------
//--- PixelShader ---
float4 SimplePixelShader(PixelShaderInput input) : COLOR
{
    return input.Color;
}

//------------------
//--- Techniques ---
technique DepthMap
{
    pass P0
    {
          VertexShader = compile vs_2_0 SimpleVertexShader();
          PixelShader = compile ps_2_0 SimplePixelShader();
    }
}